export DYLD_LIBRARY_PATH=/Library/Frameworks/GEOS.framework/unix/lib
dropdb repsheet_db
createuser -SDRP repsheet
createdb -O repsheet repsheet_db
createlang plpgsql repsheet_db
psql -d repsheet_db  -f /usr/local/pgsql/share/lwpostgis.sql
psql -d repsheet_db  -f /usr/local/pgsql/share/spatial_ref_sys.sql
psql repsheet_db <<END
ALTER TABLE geometry_columns OWNER TO repsheet;
ALTER TABLE spatial_ref_sys OWNER TO repsheet;
--INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 3435, 'epsg', 3435, '+proj=tmerc +lat_0=36.66666666666666 +lon_0=-88.33333333333333 +k=0.9999749999999999 +x_0=300000.0000000001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs ', 'PROJCS["NAD83 / Illinois East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",36.66666666666666],PARAMETER["central_meridian",-88.33333333333333],PARAMETER["scale_factor",0.999975],PARAMETER["false_easting",984250.0000000002],PARAMETER["false_northing",0],AUTHORITY["EPSG","3435"],AXIS["X",EAST],AXIS["Y",NORTH]]');
END
python <<END
import os,sys
sys.path.insert(0, "apps")
sys.path.insert(0, "..")
os.environ['DJANGO_SETTINGS_MODULE']='repsheet.settings'
from django.contrib.gis.utils import add_postgis_srs
try:
    add_postgis_srs(3435)
    print 'added srs 3435'
except:
    # not sure why, but it works the second time around
    add_postgis_srs(3435)
    print 'added srs 3435'
END

